import { Component, OnInit } from '@angular/core';
import { NzModalRef } from 'ng-zorro-antd/modal';

@Component({
  selector: 'app-codemirror',
  templateUrl: './codemirror.component.html'
})
export class CodemirrorComponent implements OnInit {
  list: any[] = ['mysql', 'oracle'];

  dbType: any = '';
  codeOptions: any = {
    theme: 'idea',
    mode: 'application/json',
    readOnly: false,
    codeSize: 'default',
    codeTitle: 'code editor',
    codeConent: ''
  };

  codeMirrorOptions: any = {
    theme: 'idea',
    mode: 'application/json',
    lineNumbers: true,
    autoRefresh: true,
    readOnly: false
  };

  constructor(private modal: NzModalRef) {}

  ngOnInit(): void {
    this.codeMirrorOptions = {
      theme: this.codeOptions.theme,
      mode: this.codeOptions.mode,
      lineNumbers: true,
      autoRefresh: true,
      readOnly: this.codeOptions.readOnly
    };
    console.log(this.codeMirrorOptions);
  }

  submit() {
    this.modal.close('ok');
  }

  close() {
    this.modal.destroy();
  }
}
